package com.taoge.p4.sys;

import com.taoge.p4.common.entity.CategoryBrand;
import com.taoge.p4.common.entity.ResponseData;
import com.taoge.p4.common.params.BrandAddProductCategoryParam;
import com.taoge.p4.common.params.ProductCategoryAddBrandParam;
import com.taoge.p4.common.service.CategoryBrandService;
import com.taoge.p4.common.vo.CategoryBrandVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/sys/categoryBrand")
public class CategoryBrandController {
    private final CategoryBrandService categoryBrandService;

    @PostMapping("/add/brandCategory")
    public ResponseData<?> addBrandCategory(@RequestBody BrandAddProductCategoryParam param){
        categoryBrandService.addBrandCategory(param);
        return ResponseData.success();
    }

    @GetMapping("/select/brandCategory")
    public ResponseData<?> selectBrandCategory(@RequestParam Long brandId){
        List<CategoryBrandVO> categoryBrandList = categoryBrandService.selectBrandCategory(brandId);
        return ResponseData.success("",categoryBrandList);
    }

    @PostMapping("/add/categoryBrand")
    public ResponseData<?> addCategoryBrand(@RequestBody ProductCategoryAddBrandParam param){
        categoryBrandService.addCategoryBrand(param);
        return ResponseData.success();
    }

    @GetMapping("/select/productCategoryBrand")
    public ResponseData<?> selectProductCategory(@RequestParam Long productCategoryId){
        List<CategoryBrandVO> brandProductCategoryList = categoryBrandService.selectProductCategory(productCategoryId);
        return ResponseData.success("",brandProductCategoryList);
    }
}
